" -----------------------------------------------------------------------------
"  < cscope 工具配置 >
" -----------------------------------------------------------------------------
" 用Cscope自己的话说 - 你可以把它当做是超过频的ctags
if has("cscope")
    set nocsverb

    "使支持用 Ctrl+]  和 Ctrl+t 快捷键在代码间跳转
    set cscopetag

    "如果你想反向搜索顺序设置为1
    set csto=1

    "设定使用quickfix窗口显示cscope结果
    " set cscopequickfix=s-,d-,i-,t-,e-

    "创建当前目录cscope数据库
    " nmap ,sd  :!cs<CR>:<ESC>
    "把cscope数据库导入vim
    " if (g:islinux)
        " nmap ,sa  :cs add ~/.vim/cscope/cscope.out .<CR>:<ESC>
        "打开vim自动把cscope数据库导入vim
        "cs add /root/.vim/cscope/cscope.out .
        "创建当前目录cscope数据库并且导入vim
        " nmap ,so  :!cs<CR><CR>:cs add ~/.vim/cscope/cscope.out .<CR>:<ESC>
    " else
        " nmap ,sa  :cs add $VIM/cscope/cscope.out .<CR>:<ESC>
        "打开vim自动把cscope数据库导入vim
        "cs add $VIM/cscope/cscope.out .
        "创建当前目录cscope数据库并且导入vim
        " nmap ,so  :!cs<CR><CR>:cs add $VIM/cscope/cscope.out .<CR>:<ESC>
    " endif
    "映射查找按键

    "查找本 C 符号
    nnoremap <leader><leader>s :cs find s <C-R>=expand("<cword>")<CR><CR>
    nnoremap <leader><leader>S :scs find s <C-R>=expand("<cword>")<CR><CR>

    "查找本定义
    nnoremap <leader><leader>g :cs find g <C-R>=expand("<cword>")<CR><CR>
    nnoremap <leader><leader>G :scs find g <C-R>=expand("<cword>")<CR><CR>

    "查找本函数调用的函数
    nnoremap <leader><leader>d :cs find d <C-R>=expand("<cword>")<CR><CR>
    nnoremap <leader><leader>D :scs find d <C-R>=expand("<cword>")<CR><CR>

    "查找调用本函数的函数
    nnoremap <leader><leader>c :cs find c <C-R>=expand("<cword>")<CR><CR>
    nnoremap <leader><leader>C :scs find c <C-R>=expand("<cword>")<CR><CR>

    "查找本字符串
    nnoremap <leader><leader>t :cs find t <C-R>=expand("<cword>")<CR><CR>
    nnoremap <leader><leader>T :scs find t <C-R>=expand("<cword>")<CR><CR>

    "查找本 egrep 模式
    nnoremap <leader><leader>e :cs find e <C-R>=expand("<cword>")<CR><CR>
    nnoremap <leader><leader>E :scs find e <C-R>=expand("<cword>")<CR><CR>
endif

"映射quick窗口上下结果选择按键
" nmap <F6>,  :cn<CR>:<ESC>
" nmap <F6>.  :cp<CR>:<ESC>
